<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">
        // 默认选项
        let defaultOptions = {
            headers: {
                'Accept': '*/*',
                'Content-Type': 'application/json',
                'Cache-Control': 'no-cache'
            },
            method: 'GET'
        }

        // 用户选项
        let myOptions = {
            headers: {
                'token': 'EyxBFRXbtZIvByGpmsmmcMXaXKlwiVdh'
            },
            params: {
                'id': 13,
                'status': 2
            },
            method: 'POST'
        }

        // 使用Object.assign()合并默认选项和用户选项
        let options = Object.assign({}, defaultOptions, myOptions);
        console.log(options); // { Headers: {…}, method: 'POST' }

        // 使用扩展运算符合并默认选项和用户选项
        let options2 = {...defaultOptions, ...myOptions};
        console.log(options2); // { Headers: {…}, method: 'POST' }
    </script>
</body>

</html>